package com.youlu.campus.admin.recycle.controller;

import com.alibaba.fastjson.JSON;
import com.youlu.campus.entity.recycle.dto.*;
import com.youlu.campus.service.recycle.service.RecycleOrderService;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : [dengbo]
 * @className : RecycleOrderController
 * @description : [回收订单，回收订单信息]
 * @createTime : [2022/6/23 14:37]
 */
@Slf4j
@RestController
public class RecycleOrderController {

    @Resource
    private RecycleOrderService recycleOrderService;

    /**
     * 回收订单列表
     * 回收订单列表
     * @param request 回收订单列表
     * @return
     */
    @PostMapping("/recycle/order/search")
    public QResult search(@Validated @RequestBody RecycleOrderSearchDTO request) {
        log.info("RecycleOrderController,search,request param:{}", JSON.toJSONString(request));
        return QResult.success(recycleOrderService.search(request));
    }

    /**
     * 订单核验
     * 订单核验
     * @param request 订单核验
     * @return
     */
    @PostMapping("/recycle/order/verify/op")
    public QResult verifyOp(@Validated @RequestBody RecycleOrderVerifyDTO request) {
        log.info("RecycleOrderController,verifyOp,request param:{}", JSON.toJSONString(request));
        boolean verify = recycleOrderService.verify(request);
        return QResult.success(verify);
    }

    /**
     * 订单取消
     * 订单取消
     * @param request 订单取消
     * @return
     */
    @PostMapping("/recycle/order/cancel")
    public QResult cancel(@Validated @RequestBody RecycleOrderCancelDTO request) {
        log.info("RecycleItemInfoController,cancel,request param:{}", JSON.toJSONString(request));
        boolean verify = recycleOrderService.cancel(request);
        return QResult.success(verify);
    }

    /**
     * 发送消息
     * 发送消息
     * @param request 发送消息
     * @return
     */
    @PostMapping("/recycle/order/send/msg")
    public QResult sendMsg(@Validated @RequestBody RecycleSmsSendDTO request) {
        log.info("RecycleItemInfoController,sendMsg,request param:{}", JSON.toJSONString(request));
        request.setMobile("18332066071");
        boolean verify = recycleOrderService.sendMsg(request);
        return QResult.success(verify);
    }

    /**
     * 订单转账
     * 订单转账
     * @param request 订单转账
     * @return
     */
    @PostMapping("/recycle/order/transfer")
    public QResult transfer(@Validated @RequestBody RecycleOrderTransferDTO request) {
        log.info("RecycleItemInfoController,transfer,request param:{}", JSON.toJSONString(request));
        request.setMobile("18332066071");
        boolean verify = recycleOrderService.transfer(request);
        return QResult.success(verify);
    }
}